/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package group;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import radiostation.DBManager;
import static radiostation.DBManager.*;
import radiostation.MainMenu;
import radiostation_POJOS.*;
/**
 *
 * @author elpida
 */
public class NewOrModifyGroupFrom extends javax.swing.JFrame {
    Musicgroup mg;
    MainMenu arxi;
    ArrayList<Artist> artists;
    private ArrayList<Artist> artistsRelated;//arraylist των καλλιτεχνών
    private DefaultListModel artistsRelatedModel;//modelo pou tha koumposei pano sti lista
    private ArrayList<Artist> artistsNotRelated;//arraylist  των μη συσχετισμένων με συγκεκριμένο 
    private DefaultListModel artistsNotRelatedModel;//modelo pou tha koumposei pano sti lista
    private ArrayList<Artist> musicgroupartists;
  //  private static EntityManager em;
    /**
     * Creates new form groupEditUI
     */
    public NewOrModifyGroupFrom(Musicgroup mg) {
        initComponents();
        setLocationRelativeTo(null);
 //       em =javax.persistence.Persistence.createEntityManagerFactory("RadiostationPU").createEntityManager();
        DBManager.openConnection();
        this.mg=mg;
        
        artistsRelated=new ArrayList();//δημιουργία arraylist
        artistsRelatedModel = new DefaultListModel();//ftiaxno neo montelo
        artistsNotRelated=new ArrayList();//ftiaxno neo montelo
        artistsNotRelatedModel = new DefaultListModel();//ftiaxno neo montelo
        this.musicgroupartists=new ArrayList();
    
    
     jComboBox1.removeAllItems();//αφαίρεση τιμών από ανααδυώμενη λίστα
        for (int i=1; i<32; i++){
            jComboBox1.addItem(i);
        }
        jComboBox2.removeAllItems();//αφαίρεση τιμών από ανααδυώμενη λίστα
        for (int i=1; i<13; i++){
            jComboBox2.addItem(i);
        }
        jComboBox3.removeAllItems();//αφαίρεση τιμών από ανααδυώμενη λίστα
        for (int i=1900; i<2016; i++){
            jComboBox3.addItem(i);
        }
        
        artists=new ArrayList();
        Query q1 =DBManager.getEm().createQuery("SELECT a FROM Artist a ", Artist.class);//ανάγνωση καλλιτεχνών από βάση
            
        List result = q1.getResultList();
        
        if (!result.isEmpty()) { // αν επιστραφουν αποτελέσματα
            Iterator itr=result.iterator();//
            while (itr.hasNext()){
                Artist ar1 = (Artist)itr.next();
                artists.add(ar1);
            }
        }
        
        if (mg!=null){
            Query q = DBManager.getEm().createQuery("SELECT m FROM Musicgroup m WHERE m.musicGroupId="+mg.getMusicGroupId(), Musicgroup.class);
            
            result = q.getResultList();//λίστα αποτελεσμάτων
            if (!result.isEmpty()) {
                Iterator itr=result.iterator();
                while (itr.hasNext()){//διάτρεξη καλαθιού
                    Musicgroup m=(Musicgroup)itr.next();
                    this.mg=m;
                }
            }
            jTextField1.setText(this.mg.getName());
            jComboBox1.setSelectedItem(this.mg.getFormationdate().getDate());
            jComboBox2.setSelectedItem(this.mg.getFormationdate().getMonth()+1);
            jComboBox3.setSelectedItem(this.mg.getFormationdate().getYear()+1900);
            this.musicgroupartists=new ArrayList();//(ArrayList)m.getMusicgroupArtistCollection();
            
            Iterator itr=mg.getArtistList().iterator();//    getArtistCollection().iterator();
            while (itr.hasNext()){
                this.musicgroupartists.add((Artist)itr.next());
            }
            setTitle("Τροποποίηση στοιχείων συγκροτήματος");
            jLabel1.setText("Παρακαλώ τροποποιήστε τα στοιχεία του συγκροτήματος:");
        }
        else{
            this.mg=new Musicgroup();
            this.mg.setArtistList(new ArrayList()); // setArtistCollection(new ArrayList());
            this.musicgroupartists=new ArrayList();
        }
        
        paintArtistLists();//΄φόρτωση στις 2 λίστες ανάλογα 
    }

    NewOrModifyGroupFrom() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    void paintArtistLists(){
        
        boolean found=false;//boolean για το αν το υπό εξέταση  είναι συσχετισμένο ή όχι
                
        lstAvailList.removeAll();//αφαίρεση όλων από λίστα
        lstCurrentList.removeAll();//αφαίρεση όλων από λίστα
        artistsNotRelatedModel.removeAllElements();//αφαίρεση όλων από μοντέλο
        artistsRelatedModel.removeAllElements();//αφαίρεση όλων από μοντέλο
        
        Iterator itr=artists.iterator();
        while (itr.hasNext()){
            Artist ar1 = (Artist)itr.next();
                    
            Iterator itr2=this.musicgroupartists.iterator();
            found=false;//αρχικοποίηση τιμής
            while(itr2.hasNext()){
                Artist ar2=(Artist)itr2.next();
                //αν το τρέχον  ανήκει 
                if (ar1.getArtistId()==ar2.getArtistId()){
                    found=true;
                    break;
                }
            }
            //αν το τρέχον  ανήκει 
            if (found){
                artistsRelated.add(ar1);//προσθήκη στη λίστα με τα συσχετισμένα 
                artistsRelatedModel.addElement(ar1);//ti prostheto sto modelo
            }
            else{
                artistsNotRelated.add(ar1);//προσθήκη στη λίστα με τα μη συσχετισμένα 
                artistsNotRelatedModel.addElement(ar1);//ti prostheto sto modelo
            }
        }
        
        
        lstAvailList.setModel(artistsNotRelatedModel);//vazo modelo sti list
        lstCurrentList.setModel(artistsRelatedModel);//vazo modelo sti list
        
        
        lstAvailList.repaint();//επανασχεδίαση λίστας
        lstCurrentList.repaint();//επανασχεδίαση λίστας
    }
    
    
    
    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        RadiostationPUEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("RadiostationPU").createEntityManager();
        artistQuery = java.beans.Beans.isDesignTime() ? null : RadiostationPUEntityManager.createQuery("SELECT a FROM Artist a");
        artistList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : artistQuery.getResultList();
        jTextField1 = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        lstAvailList = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        lstCurrentList = new javax.swing.JList();
        btnAdd2List = new javax.swing.JButton();
        btnSubFromList = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        btnSaveGroup = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Δημιουργία Νέου Συγκροτήματος");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jLabel2.setText("Επωνυμία  Συγκροτήματος:");

        jLabel3.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jLabel3.setText("Ημερομηνία Δημιουργίας:");

        jComboBox1.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel4.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jLabel4.setText("Διαθέσιμοι Καλλιτέχνες");
        jLabel4.setToolTipText("");

        jLabel5.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jLabel5.setText("Καλλιτέχνες Συγκροτήματος");

        lstAvailList.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lstAvailList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(lstAvailList);

        lstCurrentList.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lstCurrentList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane2.setViewportView(lstCurrentList);

        btnAdd2List.setText(">");
        btnAdd2List.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdd2ListActionPerformed(evt);
            }
        });

        btnSubFromList.setText("<");
        btnSubFromList.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSubFromListActionPerformed(evt);
            }
        });

        jButton4.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cancel.png"))); // NOI18N
        jButton4.setText("Ακύρωση");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        btnSaveGroup.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        btnSaveGroup.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Check.png"))); // NOI18N
        btnSaveGroup.setText("Αποθήκευση");
        btnSaveGroup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveGroupActionPerformed(evt);
            }
        });

        jLabel1.setBackground(new java.awt.Color(204, 204, 255));
        jLabel1.setFont(new java.awt.Font("Monotype Corsiva", 1, 14)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 0, 255));
        jLabel1.setText("  Παρακαλώ  εισάγετε  τα  στοιχεία  του  νέου συγκροτήματος:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(30, 30, 30)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(btnAdd2List)
                                    .addComponent(btnSubFromList)))
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnSaveGroup)
                        .addGap(43, 43, 43)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jButton4))
                .addGap(42, 42, 42))
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(21, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 432, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnAdd2List)
                        .addGap(36, 36, 36)
                        .addComponent(btnSubFromList)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4)
                    .addComponent(btnSaveGroup))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void btnAdd2ListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdd2ListActionPerformed
        // TODO add your handling code here:
         if (lstAvailList.getSelectedIndex()>=0){//αν επέλεξα κάτι από τα
            Artist a=(Artist)lstAvailList.getSelectedValue();//πιάνω το επιλεγμένο 
            this.musicgroupartists.add(a);
            mg.getArtistList().add(a);//  getArtistCollection().add(a);
            a.getMusicgroupList().add(mg);//  getMusicgroupCollection().add(mg);
            paintArtistLists();//επανασχεδίαση λιστών
        }
        else{
            JOptionPane.showMessageDialog(null, "Δεν επιλέξατε κάποιον απο τους καλλιτέχνες", "Λάθος", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btnAdd2ListActionPerformed

    private void btnSubFromListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubFromListActionPerformed
        // TODO add your handling code here:
         if (lstCurrentList.getSelectedIndex()>=0){//αν επέλεξα κάτι από τα καταστήματα
            Artist artist=(Artist)lstCurrentList.getSelectedValue();//πιάνω το επιλεγμένο προϊόν
           
            //}
            Iterator itr2=this.musicgroupartists.iterator();//δείκτης  
            while(itr2.hasNext()){
                Artist a2 = (Artist)itr2.next();
                //αν το τρέχον προϊόν ανήκει στα προϊόντα του κατατήματος
                if (artist.getArtistId()==a2.getArtistId()){
                    this.musicgroupartists.remove(a2);
                    break;
                }
            }
            paintArtistLists();//επανασχεδίαση λιστών
        }
        else{
            JOptionPane.showMessageDialog(null, "Δεν επιλέξατε κάποιον απο τους καλλιτέχνες", "Λάθος", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btnSubFromListActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        //arxi.rm.groupUI=new ListGroupFrom(arxi);//άνοιγμα προηγούμενης φόρμας
        //arxi.rm.groupUI.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
        //arxi.rm.groupUI.setVisible(true);
 //       new ListMusicGroupForm().setVisible(true);
        this.dispose();//kleisimo formas
    }//GEN-LAST:event_jButton4ActionPerformed

    private void btnSaveGroupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveGroupActionPerformed
        // TODO add your handling code here:
        // TODO add your handling code here:
        if (!DBManager.getEm().getTransaction().isActive()){
            DBManager.getEm().getTransaction().begin();
        }
        try{
            this.mg.setName(jTextField1.getText());
            Date d = new Date();
            d.setDate((int) jComboBox1.getSelectedItem());
            d.setMonth((int) jComboBox2.getSelectedItem()-1);
            d.setYear((int) jComboBox3.getSelectedItem()-1900);
            this.mg.setFormationdate(d);
            //έλεγχος για συμπλήρωση υποχρεωτικών πεδίων
            if (!this.mg.getName().equals("") && this.musicgroupartists.size()>=2){
                //this.mg.setMusicgroupArtistCollection(this.musicgroupartists);
                this.mg.setArtistList(musicgroupartists);// setArtistCollection(artistList);
                System.out.println(this.mg.getMusicGroupId());
                System.out.println(musicgroupartists);
                DBManager.getEm().persist(this.mg);//προσθήκη στη transaction με τη βάση

                DBManager.getEm().getTransaction().commit();//πραγματοποίηση αλλαγών στη βάση
       //         new ListMusicGroupForm().setVisible(true);
                this.dispose();//kleisimo formas
            }
            else{
                 JOptionPane.showMessageDialog(null, "Συμπληρώστε το ονομα και δώστε τουλάχιστον 2 καλλιτέχνες", "Σφάλμα", JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception e) {
            e.printStackTrace();
            DBManager.getEm().getTransaction().rollback();
        }  
    }//GEN-LAST:event_btnSaveGroupActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        // TODO add your handling code here:
        new ListMusicGroupForm().setVisible(true);
    }//GEN-LAST:event_formWindowClosed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewOrModifyGroupFrom.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewOrModifyGroupFrom.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewOrModifyGroupFrom.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewOrModifyGroupFrom.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewOrModifyGroupFrom().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.persistence.EntityManager RadiostationPUEntityManager;
    private java.util.List<radiostation_POJOS.Artist> artistList;
    private javax.persistence.Query artistQuery;
    private javax.swing.JButton btnAdd2List;
    private javax.swing.JButton btnSaveGroup;
    private javax.swing.JButton btnSubFromList;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JList lstAvailList;
    private javax.swing.JList lstCurrentList;
    // End of variables declaration//GEN-END:variables
}
